Fix use-after-free of temp in gbfile. That gets Ubuntu back to a happy place.
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 10 Feb 2013 03:38:11 +0000 (03:38 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 10 Feb 2013 03:38:11 +0000 (03:38 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4301 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/gbfile.cc

index 2cbd8edbb2bca9558e240353fc1bc47f0b42c648..376d2b2c83f3fc46cc0fe531bc712390479a64f5 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <QtCore/QDebug>
 
 
 #if __WIN32__
@@ -779,9 +780,11 @@ gbfputs(const char* s, gbfile* file)
 int
 gbfputs(const QString& s, gbfile* file)
 {
-  const char* qs = s.toUtf8().data();
+  const char* qs = xstrdup(s.toUtf8().data());
   unsigned int l = strlen(qs);
-  return gbfwrite(qs, 1, l, file);
+  int rv =  gbfwrite(qs, 1, l, file);
+  xfree(qs);
+  return rv;
 }
 
 /*